﻿using DeHeng_Mes.Dao;
using DeHeng_Mes.Dao.PlcDao;
using DeHeng_Mes.Model.ConfigModel;
using DeHeng_Mes.Model.Table;
using DeHeng_Mes.Utils;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeHeng_Mes.Service
{
    class spotCheakService
    {
        public  void StationSpotChackSave(PlcOrderConfigModel orderModel, string cheakCode ,string station)
        {

            PlcDao plcDao = new PlcDao();

            try
            {
                string date = DateTime.Now.ToString("yyyy-MM-dd");

                if (!plcDao.QuearCheck(date,station))
                {
                    plcDao.SpotChackSave(new SpotChack()
                    {
                        PlcName = orderModel.PlcName,
                        CreateTime = DateTime.Now,
                        Station = station,
                        TraceId = cheakCode,
                        Status = "1",
                    });
                    Tools.ProduceLogText($"[{station}]执行点检任务成功,点检码[{cheakCode}]");
                }
               

            

            }
            catch (Exception ex)
            {
              Tools.ProduceLogTextError($"[{station}]执行点检任务失败,报警信息:{ex.Message}");
            }

        }
    }
    
}
